home *** CD-ROM | disk | FTP | other *** search
- Path: newshub.cts.com!usenet
- From: jfitz@vmbb.cts.com (Jim Fitzgerald)
- Newsgroups: comp.lang.c
- Subject: Type conversion
- Date: Mon, 29 Jan 1996 23:01:38 GMT
- Organization: CTS Network Services
- Message-ID: <4ejjka$2rf@news3.cts.com>
- NNTP-Posting-Host: neutrino.cts.com
-
-
- Hi,
-
- Was wondering if a guru out there could tell me why the following
- code fragment for extracting an long from a buffer does not work.
- Following the bad code, is a fragment that does work.. but is fairly
- cheezy! )..
-
- This code compiles and runs but returns INCORRECT results:
-
- char buffer[512];
- long node_left, node_right;
- {
- node_left = (long)*(buffer+4);
- node_right= (long)*(buffer+8);
- }
-
- This code runs and returns CORRECT results:
-
- char buffer[512];
- long node_left, node_right;
- long *bogus;
- {
- bogus = buffer+4;
- node_left = *bogus;
- bogus = buffer+8;
- node_right= *bogus;
- }
-
- Thanks!
- -Jim
-
-
-